Skip to content

feat(python): expose PriorFactor<EssentialMatrix> to Python wrapper#2562

Open
SidArora29 wants to merge 1 commit into
borglab:developfrom
SidArora29:feat-prior-essential-matrix
Open

feat(python): expose PriorFactor<EssentialMatrix> to Python wrapper#2562
SidArora29 wants to merge 1 commit into
borglab:developfrom
SidArora29:feat-prior-essential-matrix

Conversation

@SidArora29

Copy link
Copy Markdown
Contributor

Summary

This PR exposes the PriorFactor<EssentialMatrix> template instantiation to the Python wrapper in gtsam/nonlinear/nonlinear.i.

While gtsam::EssentialMatrix is a fully defined 5-DoF manifold in the C++ core (gtsam/geometry/EssentialMatrix.h), its corresponding prior factor (PriorFactor) was previously omitted from the Python interface. Exposing this class allows researchers and engineers working in Python to place a direct prior anchor constraint on an Essential Matrix (representing relative camera rotation and unit translation direction) during non-linear optimization.

Changes

  • Added gtsam::EssentialMatrix to the template type parameter list T of PriorFactor in gtsam/nonlinear/nonlinear.i.
  • This triggers the auto-generation of the gtsam.PriorFactorEssentialMatrix binding class during the build phase.

How This Was Tested

  1. Compiled GTSAM from source locally with Python bindings enabled (-DGTSAM_BUILD_PYTHON=ON).
  2. Verified that the PriorFactorEssentialMatrix class is correctly generated, exposed, and functional inside a Python 3.10 interpreter:
import gtsam

# Create a key
key = 1

# Create an Essential Matrix (Identity rotation, unit translation along X)
rot = gtsam.Rot3()
direction = gtsam.Unit3(1.0, 0.0, 0.0)
essential = gtsam.EssentialMatrix(rot, direction)

# Create a 5-DoF noise model for the Essential Matrix tangent space
noise = gtsam.noiseModel.Isotropic.Precision(5, 100.0)

# Instantiate the newly exposed PriorFactor!
prior = gtsam.PriorFactorEssentialMatrix(key, essential, noise)

print(prior)
# Output:
# PriorFactor on 1
#   prior mean: R:
#  [
# 	1, 0, 0;
# 	0, 1, 0;
# 	0, 0, 1
# ]
# d: :1
# 0
# 0
# isotropic dim=5 sigma=0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant